#!/usr/bin/python3
import requests
import time
import random
headers = {}#请在此填入headers信息
url = r"请在此填入URL信息"
d = r'请在此填入data信息'


def slp(n):
    t = int(n)
    for i in range(t):
        time.sleep(1)
        print('.',end='',flush=True)
    time.sleep(n - t)
    print('')

sleep = 4
adv = 0
n = input("请输入数量:")
try:
    n = int(n)
except:
    try:
        n, sleep, adv = int(n.split()[0]),float(n.split()[1]),int(n.split()[2])
    except:
        n, sleep = int(n.split()[0]),float(n.split()[1])
        
err = 0
werr = 0
for i in range(n):
    headers["Cookie"]=headers["Cookie"][:-22]+str(random.randint(1*(10**20),9*(10**20)))+'"'
    print(f"[{i}/{n}]",end='')
    try:
        t = time.time()
        if adv == 1:
            r = requests.post(url,headers=headers,data=d,verify=False)
        else:
            r = requests.post(url,headers=headers,data=d)
        t = time.time() - t
        print(f"[{t}]",end='')
        if r.status_code == 200:
            try:
                if r.json()["success"] == True:
                    print("请求成功")
                    werr = 0
                else:
                    raise EOFError
            except:
                err += 1
                print(f"请求失败[{err}]")
                print(r.text)
                werr += 1

        else:
            err += 1
            print(f"请求失败[{err}]")
            print(r.text,r.json()["success"])
            werr += 1
    except:
        err += 1
        print(f"请求异常[{err}]")
    if(werr > 5):
        slp(3600)
    elif(werr > 4):
        slp(600)
    elif(werr > 3):
        slp(60)
    elif(werr > 2):
        slp(20)
    slp(sleep)
